import React, { Component } from 'react'
import types from 'prop-types'
import Message from './Message'

export default class Product extends Component {
  render() {
    return (
      <div>
        optionalNode:{this.props.optionalNode}
        <hr/>
        {
          this.props.optionalMessage.getName()
        }
      </div>
    )
  }
}

Product.propTypes ={
  name:types.string.isRequired,
  price:types.number,
  optionalNode: types.node,
  optionalElement: types.element,
  optionalElementType: types.elementType,
  optionalMessage: types.instanceOf(Message).isRequired,
  city: function(props, propName, componentName) {
    console.log(props,propName,componentName)
    if (!/太原/.test(props[propName])) {
      return new Error(
        '城市名称太原不存在'
      );
    }
  }
}


